/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package codegen.ui.nbvisual.visual;

import java.awt.Color;
import java.awt.Graphics2D;
import org.netbeans.api.visual.widget.LayerWidget;
import org.netbeans.api.visual.widget.Scene;

/**
 *
 * @author cuong.nguyenmanh2
 */
public class GridLayerWidget extends LayerWidget {

    public GridLayerWidget(Scene scene) {
        super(scene);

        setBackground(new Color(0.9f, 0.9f, 0.9f));
        setForeground(Color.red);
        setOpaque(true);
    }

    @Override
    protected void paintBackground() {
        super.paintBackground();
        int width, height;
        int rows = 10;
        int cols = 10;
        Graphics2D g = getGraphics();
        int i;
        width = this.getBounds().width;
        height = this.getBounds().height;

        width = 800;
        height = 600;
        Color lightDark = new Color(0.5f,0.5f,0.5f);
        g.setColor(lightDark);
        // draw the rows
        int rowHt = height / (rows);
        int rowWid = width / (cols);
        
        rowHt = 20;
        rowWid = 20;
        rows = height / rowHt;
        cols = width / rowWid;
        for (i = 0; i < rows; i++) {
            g.drawLine(0, i * rowHt, width, i * rowHt);
        }

        // draw the columns
        
        for (i = 0; i < cols; i++) {
            g.drawLine(i * rowWid, 0, i * rowWid, height);
        }
    }
}
